/**
 * 菜单展现JS
 * 2008-2-27
 * @author Jacky Chen
 */

function linkURL(url){
	$("mainframe").src = url; 
}
/**
 * 初始化
 * 2008-2-27
 * @author Jacky Chen
 */
window.onload = function(){
	FrontAction.getTreeMap(showMenue);
}

/**
 * 递归展示菜单
 * 2008-2-27
 * @author Jacky Chen
 * @param {Object} data
 */
function showMenue(data){
	if(data){
		var htmlStr = "<ul>";
		for(var i=0;i<data[0].length;i++){
			htmlStr += "<li id=\""+data[0][i].id+"\"><a href=\"javascript:linkURL('"+data[0][i].url+"')\">"+data[0][i].menuname+"</a>";
			htmlStr += showChildMenue(data[0][i].id,data);
			htmlStr += "</li>";
		}
		htmlStr += "</ul>";
		$("dhtmlgoodies_slidedown_menu").innerHTML = htmlStr;
		initSlideDownMenu();
		document.getElementById('dhtmlgoodies_slidedown_menu').style.display = "";
	}
}

/**
 * 递归展示菜单(递归子的)
 * 2008-2-27
 * @author Jacky Chen
 * @param {Object} pId
 * @param {Object} data
 */
function showChildMenue(pId,data){
	var htmlStr = "";
	if(data[pId]){
		htmlStr += "<ul>";
		for(var i=0;i<data[pId].length;i++){
			htmlStr += "<li id=\""+data[pId][i].id+"\"><a href=\"javascript:linkURL('"+data[pId][i].url+"')\">"+data[pId][i].menuname+"</a>";
			htmlStr += showChildMenue(data[pId][i].id,data);
			htmlStr += "</li>";
		}
		htmlStr += "</ul>";	
	}
	return htmlStr;
}